package com.heo.music.player.dto.output;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.ArrayList;
import java.util.List;


/**
 * @author liukang
 */
@Data
@ApiModel(description = "分页信息")
@NoArgsConstructor
@AllArgsConstructor
public class PageOutput<T> {


    /**
     * 一共的页数
     */
    @ApiModelProperty(value = "总共页数", example = "1", required = true, position = -999)
    private int totalPages;

    /**
     * 总数据
     */
    @ApiModelProperty(value = "总共的数据量", example = "3", required = true, position = -998)
    private long totalElements;

    /**
     * 数据
     */
    @ApiModelProperty(value = "数据",required = true)
    private List<T> data;


    public PageOutput<T> empty() {
        this.totalPages = 0;
        this.totalElements = 0;
        this.setData(new ArrayList<>());
        return this;
    }

}
